package com.example.demo.controller;

import com.example.demo.mq.RabbitService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @author ghl
 * @version 1.0
 * @date 2022/9/21 14:55
 * @description 测试广播消息 扇形交换机
 */
@RestController
public class RabbitController {

    private static final Logger logger = LoggerFactory.getLogger(RabbitController.class);

    @Autowired
    RabbitService rabbitService;

    @GetMapping("/test")
    public String sendMq() {
        Map<String, String> map = new HashMap<>();
        String uuid = UUID.randomUUID().toString();
        map.put("UUID", uuid);
        String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        map.put("TIME", format);
        rabbitService.sendMessage("fanoutExchange", "", map);
        return "消息发送成功";
    }


}
